﻿using furion.blog.Application.Contracts;
using furion.blog.Domain.Shared.Attribute;
using furion.blog.Utils;
using Furion.DynamicApiController;
using Microsoft.AspNetCore.Mvc;

namespace furion.blog.Web.Entry.Api
{
    /// <summary>
    /// 邮件发送日志相关接口
    /// </summary>
    [ApiDescriptionSettings(Groups = new string[] { "EmailSendLogApi" })]
    [Route("api/emailSendLog")]
    public class EmailSendLogApiController : IDynamicApiController
    {
        private readonly IEmailSendLogService _emailSendLogService;
        public EmailSendLogApiController(IEmailSendLogService emailSendLogService) {
            this._emailSendLogService = emailSendLogService;
        }

        [ActionAttribute(Name = "邮件发送日志分页接口", Desc = "邮件发送日志分页数据")]
        [HttpGet, Route("list")]
        public async Task<IActionResult> list(
         [FromQuery(Name = "page")] int pageIndex,
         [FromQuery(Name = "limit")] int pageSize,
         [FromQuery(Name = "searchContent")] string searchContent = "",
         [FromQuery(Name = "date")] string date = "",
         [FromQuery(Name = "status")] string status = ""
         )
        {
            var ret = await this._emailSendLogService.List(new Domain.Query.EmailSendLog.EmailSendLogListQuery
            {
                PageIndex = pageIndex,
                PageSize = pageSize,
                SearchContent = searchContent,
                Date = date,
                Status = status,
            });
            return new OkObjectResult(ResultUtil.Success(ret));
        }

    }
}
